const path = require('path')
const ejs = require('ejs')

module.exports = (templateDir, data) => {
  template = path.resolve(__dirname, './template', templateDir)
  // console.log(template)
  const promise = new Promise((resolve, reject) => {
    ejs.renderFile(template, data, {}, (err, str) => {
      if (err) {
        reject(err)
        return
      }
      resolve(str)
    });
  })
  return promise
}
